module.exports = function(success,error){
    if(typeof error != 'function'){
        error = ()=>{
            console.log('出现错误')
        }
    }

    const mongoose = require('mongoose')
    mongoose.set('strictQuery', false)
    const {DBHOST,DBPORT,DBNAME} = require('../config/dc')

    mongoose.connect(`mongodb://${DBHOST}:${DBPORT}/${DBNAME}`)
    mongoose.connection.once('open',()=>{
        success()
    })
    mongoose.connection.on('error',()=>{
        error()
    })
    mongoose.connection.on('close',()=>{
        console.log('服务器已经关闭')
    })
}